home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1991 / 04 / v_constr.c < prev    next >
C/C++ Source or Header  |  1991-05-03  |  1KB  |  39 lines

  1. /*    v_constr.c- Initialize a viewport */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. #include <tools/viewport.h>
  7.  
  8. int v_construct( viewport *v )
  9. {
  10.     /* Initialize a previously allocated (with malloc() or a declaration)
  11.      * viewport, setting various fields to reasonable defaults. It's an
  12.      * error to construct a viewport more than once without an intervening
  13.      * v_destroy call.
  14.      */
  15.  
  16.     struct text_info info;
  17.     gettextinfo( &info );
  18.  
  19.     if( v->magic == VMAGIC )
  20.         return 0;
  21.  
  22.     v->magic     = VMAGIC;
  23.     v->inactive  = 1;
  24.     v->closed    = 1;
  25.     v->clearok   = 0;
  26.     v->saveok    = 0;
  27.     v->nrows     = info.screenheight;   /* Initial size is the entire screen */
  28.     v->ncols     = info.screenwidth;
  29.     v->row       = 0;                   /* Upper-left corner */
  30.     v->col       = 0;
  31.     v->cur_col   = 0;
  32.     v->cur_row   = 0;
  33.     v->fcolor    = BLACK ;
  34.     v->bcolor    = LIGHTGRAY ;
  35.     v->savebuf   = NULL;
  36.     v->old_image = NULL;
  37.     return 1;
  38. }
  39.